package com.example.demo;

import java.util.List;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Scope;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import com.alibaba.fastjson.JSONObject;
import feign.Feign;
import feign.codec.Decoder;

@FeignClient(name = "demoFeign", url = "http://localhost:8080" //
//    , configuration = CustomizedConfiguration.class //
)
public interface DemoFeign {

  @PostMapping(value = "/open/post")
  public <R extends BaseResponse, T extends BaseRequest> R invoke(@RequestBody T request);

  @PostMapping(value = "/open/post")
  public Response01 invoke1(@RequestBody Request01 request);

  @PostMapping(value = "/open/post")
  public Response02 invoke2(@RequestBody Request02 request);

  @PostMapping(value = "/open/post")
  public List<List<Response02>> invoke3(@RequestBody JSONObject request);
  
  @PostMapping(value = "/open/error")
  public String error();

  public class CustomizedConfiguration {
    @Bean
    public Decoder feignDecoder() {
      return new GenericsFeignResultDecoder();
    }

    @Bean
    @Scope("prototype")
    public Feign.Builder feignBuilder() {
      return Feign.builder();

    }
  }
}
